//
//  MLWWWCollectionTableViewCell.m
//  KITCHEN_STORIES
//
//  Created by 孟令通 on 16/6/15.
//  Copyright © 2016年 MLW. All rights reserved.
//

#import "MLWWWCollectionTableViewCell.h"

#import "MLWBaseView.h"

@implementation MLWWWCollectionTableViewCell

- (void)dealloc {
    [_mainImageView release];
    [_topImageView release];
    [_moddleImageView release];
    [_bottomImageView release];
    [_smallLabel release];
    [_bigLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.mainImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:_mainImageView];
        [_mainImageView release];
        
        self.topImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:_topImageView];
        [_topImageView release];
        
        self.moddleImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:_moddleImageView];
        [_moddleImageView release];
        
        self.bottomImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:_bottomImageView];
        [_bottomImageView release];
        
        self.smallLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_smallLabel];
        [_smallLabel release];
        
        self.bigLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_bigLabel];
        [_bigLabel release];
        
    }
    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.mainImageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(10);
        make.height.equalTo(92);
        make.width.equalTo(141);
        
    }];
    
    [self.topImageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.mainImageView.right).offset(1);
        make.right.equalTo(self.contentView.right);
        make.height.equalTo(30);
    }];
    
    [self.moddleImageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.topImageView.bottom).offset(1);
        make.left.equalTo(self.mainImageView.right).offset(1);
        make.right.equalTo(self.contentView.right);
        make.height.equalTo(30);
    }];
    
    [self.bottomImageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.moddleImageView.bottom).offset(1);
        make.left.equalTo(self.mainImageView.right).offset(1);
        make.right.equalTo(self.contentView);
        make.bottom.equalTo(self.mainImageView.bottom);
    }];
    
    [self.bigLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.mainImageView.bottom).offset(8);
        make.left.equalTo(self.mainImageView);
        make.right.equalTo(self.mainImageView);
        make.bottom.equalTo(self.contentView.bottom).offset(-10);
        
    }];
    
    [self.smallLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(65);
        make.left.equalTo(self.mainImageView).offset(40);
        make.right.equalTo(self.mainImageView).offset(-40);
        make.height.equalTo(15);
        
    }];
    
}


-(void)setHotItemModel:(MLWWWHotItemModel *)hotItemModel
{
    if (_hotItemModel != hotItemModel) {
        [_hotItemModel release];
        _hotItemModel = [hotItemModel retain];
        self.bigLabel.text = hotItemModel.Title;
        self.bigLabel.textAlignment = 1;
        
        self.smallLabel.text = hotItemModel.Recipe;
        self.smallLabel.textAlignment = 1;
        
        [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:hotItemModel.Img] placeholderImage:[UIImage imageNamed:@""]];
        
        MLWWWHotItemImageModel *model = hotItemModel.List[0];
        
        [self.topImageView sd_setImageWithURL:[NSURL URLWithString:model.Cover] placeholderImage:[UIImage imageNamed:@""]];
        
        MLWWWHotItemImageModel *twoModel = hotItemModel.List[1];
        
        [self.moddleImageView sd_setImageWithURL:[NSURL URLWithString:twoModel.Cover] placeholderImage:[UIImage imageNamed:@""]];
        
        MLWWWHotItemImageModel *threeModel = hotItemModel.List[2];
        
        [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:threeModel.Cover] placeholderImage:[UIImage imageNamed:@""]];
        
    }
}



@end
